<?php
if (isset($_POST['btnSent'])) {
	$str = strtolower($_POST['capcha']);
	if ($_SESSION['captcha_code'] != $str) {
		$error="<font color='#FF0000'><i>Nhập sai mã số.</i></font>"; // xử lý lỗi
	}
	else {
		if($_SESSION['date_end'] <= date('i')){
			include_once 'capcha/sendmail.php';
			$_SESSION['date_start'] = date('i');
		}
		if(!@$_SESSION['date_start']) $_SESSION['date_start'] = date('i');
		$_SESSION['date_end'] = $_SESSION['date_start'] + 5;
	}
}
$contact = "
<div id='viewpost'>
<div id='navigator'><img style='float:left' src='images/title_1.png' alt='' /><p>Liên hệ</p><img style='float:right' src='images/title_3.gif' alt='' /></div>
<div style='clear:both; margin:10px 10px'>

	<h1 style='font-size:13px; line-height:22px'>VIỆN NGHIÊN CỨU KINH TẾ & QUẢN TRỊ NHÂN SỰ<br />ECONOMIC RESEARCH AND HUMAN MANAGEMENT INSTITUTE </h1>
	<p style='line-height:20px'><b>Trụ sở:</b> 243/12 Chu Văn An, Phường 12, Quận Bình Thạnh, TP.HCM<br />
	<b>Văn phòng ĐD:</b> 1A Nguyễn Văn Lượng, Phường 6, Quận Gò Vấp, TP.HCM<br />
	<b>Tel:</b>(08) 2242 9375 &nbsp; - &nbsp; <b>Hotline:</b> 0937 279 399 - Email: info@rehmi.org<br />
	<br />
	<script language='javascript'>
		function KiemTra() {
			myFrmObj = document.comment
			
			if(myFrmObj.FullName.value == '') {
				window.alert('Please enter a valid name.');
				myFrmObj.FullName.focus('FullName');
				return false;
			}
			else if(myFrmObj.Email.value == '') {
				window.alert('Please enter an email address.');
				myFrmObj.Email.focus('Email');
				return false;
			}
			else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myFrmObj.Email.value))){
				window.alert('Please enter a valid email address.');
				myFrmObj.Email.focus('Email');
				return false;
			}
			else if(myFrmObj.Comment.value == '') {
				window.alert('Please write your comments here.');
				myFrmObj.Comment.focus('Comment');
				return false;
			}
			else if(myFrmObj.capcha.value == '') {
				window.alert('Please enter a valid security code');
				myFrmObj.capcha.focus('capcha');
				return false;
			}
			return true;
		}
	</script>
    <form action='' method='post' name='comment' onSubmit='return KiemTra()'>
    <table width='500' align='center' border='0' cellspacing='5' cellpadding='5'>
      <tr>
        <td align='right'>Họ tên: <span style='color:#FF0000'>*</span></td>
        <td><input type='text' name='FullName' value='{$_POST['FullName']}' maxlength='50' class='txt' /></td>
      </tr>
      <tr>
        <td align='right'>Email: <span style='color:#FF0000'>*</span></td>
        <td><input type='text' name='Email' value='{$_POST['Email']}' maxlength='50' class='txt' /></td>
      </tr>
      <tr>
        <td align='right'>Địa chỉ:</td>
        <td><input type='text' name='Address' value='{$_POST['Address']}' maxlength='250' class='txt' /></td>
      </tr>
      <tr>
        <td align='right'>Điện thoại:</td>
        <td><input type='text' name='Tel' value='{$_POST['Tel']}' maxlength='50' class='txt' /></td>
      </tr>
      <tr>
        <td width='110' align='right'>Tiêu đề: <span style='color:#FF0000'>*</span></td>
        <td><input type='text' name='Title' value='{$_POST['Title']}' maxlength='200' class='txt' /></td>
      </tr>
      <tr>
        <td align='right' valign='top'>Nội dung: <span style='color:#FF0000'>*</span></td>
        <td><textarea name='Comment' class='textarea'>{$_POST['Comment']}</textarea></td>
      </tr>
        <tr>
          <td align='right' valign='top'>Mã kiểm tra:<span style='color:#FF0000'> *</span></td>
          <td><input name='capcha' type='text' id='capcha' class='txt' maxlength='5' value='{$_POST['capcha']}' />
              <br /><img src='capcha/capcha_image.php' /><br />{$error}</td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type='submit' name='btnSent' value='Gửi' class='btn' /><input type='reset' name='btnCancel' value='Hủy' class='btn' /></td>
      </tr>
    </table>
  </form>
</div></div>
";